define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'paotui/worker/index' + location.search,
                    add_url: 'paotui/worker/add',
                    edit_url: 'paotui/worker/edit',
                    del_url: 'paotui/worker/del',
                    multi_url: 'paotui/worker/multi',
                    import_url: 'paotui/worker/import',
                    table: 'paotui_poster',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
				search:false,
				showColumns: false,
				showToggle: false,
				// commonSearch: false,
				showExport: false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),operate:false},
                        {field: 'poster_name', title: __('取件人姓名'), operate: 'LIKE'},
                        {field: 'mobile', title: __('手机号'), operate: 'LIKE'},
                        {field: 'agentname', title: __('分销商'),operate:false},
                        {field: 'schoolname', title: __('学校')},
                        {field: 'poster_type', title: __('类型'),formatter: function(value,row){
                                if(value != 1){
                                    return '在线时长（'+row['brokerage_scale']+'元/H）';
                                }else{
                                    return "<span style='color: #1bbd62'>个数（"+row['brokerage_scale']+"元/个）</span>";
                                }
                            }, searchList: {1: __('在线时长'), 2: __('个数')}},
                        {field: 'money', title: __('剩余佣金'), operate: false},
                        {field: 'is_online', title: __('是否在线'), sortable:true,formatter: Table.api.formatter.status, searchList: {1: __('是'), 0: __('否')}},
                        {field: 'is_order', title: __('是否接单中'), formatter: Table.api.formatter.status, searchList: {1: __('是'), 0: __('否')}},

                        {field: 'last_online_time', title: __('最后上线时间'), sortable:true, operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'last_offline_time', title: __('最后离线时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'status', title: __('正常/锁定'),operate: false, formatter: Table.api.formatter.toggle, searchList: {1: __('正常'), 0: __('锁定')}},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
